package com.demo.spark.rdd

import org.apache.spark.{SparkConf, SparkContext}

import scala.runtime.Nothing$

object RddTakeSampleScala {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("rdd take sample scala")
    val context = new SparkContext(conf)
    context.setLogLevel("error")
    val ints = Seq(5, 1, 0, 4, 4, 2, 2)
    val rdd = context.parallelize(ints)
    for (elem <- rdd.takeSample(true, 100)) {
      print(elem+",")
    }
    println()
    for (elem <- rdd.takeSample(true, 2,100)) {
      print(elem+",")
    }
    println()
    for (elem <- rdd.takeSample(true, 2,100)) {
      print(elem+",")
    }
    println()
  }

}
